<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>EEWAS用户信息修改</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword3">
		<meta http-equiv="description" content="This is my page">
		<script language="JavaScript" src="resource/js/util.js"></script>
		<link rel="stylesheet" type="text/css" href="resource/css/common.css">
		<style type="text/css">
		select{
			font-family: arial;
			font-size: 12px;
		}
		body{
			font-family: arial;
			font-size: 12px;
			background-color: #F9F8E8;
		}
		a{
			font-size: 12px;
			font-family: arial;
			font-weight: bold;
			color: green;
			text-decoration: none;
		}
		a:HOVER {
			color: red;
		}
		h4 {
			font-family: "宋体";	
			color: #006699;
		}
		table{
			font-size: 12px;
			font-family: arial;
			color: #234345;
		}
		.asterisk {
			color: #990000;

		}
		.allText{
			color: #006699;
			font-size: 12px;
			font-weight: normal;
		}
		.myVisibility{
			visibility="hidden";
			position="absolute";			
		}
		.div_copyright{
			top:533px;
			left: 410px;
			position: absolute;
			font-size: 11px;
			font-weight:normal;
			font-family:arial;
			color: #808080;
		}
	</style>


		<script language="JavaScript" src="resource/js/net.js"></script>
		<script language="JavaScript" src="resource/js/Calendar30.js"></script>
		<script language="javaScript">
	  WebCalendar.yearFall   = 100;           //定义年下拉框的年差值
	  WebCalendar.format     = "yyyy-mm-dd"; //回传日期的格式
  </script>

  <script language="javascript" type="text/javascript">
  function validata(rand){
    //验证码
	var number=document.myform.number.value;
	if(number.length<1){
	  alert("验证码需要填写");
	  return;
	}
	if(rand != number){
	  alert("验证码输入错误");
	  return;
	}
	//验证密码
	if(document.myform.isUpdatePwd.checked){
	   if(document.myform.oldPassword.value.length<6){
		  alert("用户密码不能少于6位");
		  return;
	   }
	   if(document.myform.password.value.length<6){
		  alert("用户密码不能少于6位");
		  return;
	   }
	   if(document.myform.password2.value != document.myform.password.value){
		  alert("两次密码输入不同");
		  return;
	   }
	}
	//验证密码保护信息
	if(document.myform.isSetPwdQuest.checked){
		//判断老密码
		if(document.myform.isUpdatePwd.checked){
			if(document.myform.oldPassword.value != document.myform.password3.value){
				alert("两次输入老密码错误。");
				return;
			}
		}else{
			if(document.myform.password3.value.length<6){
			  alert("验证密码保护的用户密码不能少于6位");
			  return;
		   }
	   }
	   var pqav = document.myform.passQuestionAnswer.value;
	   pqav = pqav.trim();
	   document.myform.passQuestionAnswer.value = pqav;
	   if(pqav.length < 4){
	   	 alert("密码提示问题请设置成4个字符以上。");
	   	 return;
	   }
	}
	//tel
	/*
	var tel=document.myform.tel.value;
	if(tel == null || tel.length<7){
		alert("电话号码格式不正确");
		return;
	}*/
	//address
	/*
	var address=document.myform.address.value;
	if(address==null || address.length<1){
		alert("联系地址格式不正确");
		return;
	}*/
	document.myform.submit();  
  }  
  
  function toVisibility(){
    var old;
    var vorh;
    var temp;
    if(document.myform.isUpdatePwd.checked){
       vorh="visible";
       temp="relative";
    }else{
       vorh="hidden";
       temp="absolute";
    }
     document.all.old_key.style.visibility=vorh;
     document.all.old_key.style.position=temp;
     document.all.pwd_key.style.visibility=vorh;
     document.all.pwd_key.style.position=temp;
     document.all.pwd_key2.style.visibility=vorh;
     document.all.pwd_key2.style.position=temp;
    // parent.TuneHeight('mainContent');
    }
    
  function toVisibilityProtected(){
    var old;
    var vorh;
    var temp;
    if(document.myform.isSetPwdQuest.checked){
       vorh="visible";
       temp="relative";
    }else{
       vorh="hidden";
       temp="absolute";
    }
    document.all.trPassQuest.style.visibility=vorh;
    document.all.trPassQuest.style.position=temp;
    document.all.trPassQuestAnswer.style.visibility=vorh;
    document.all.trPassQuestAnswer.style.position=temp;
    document.all.pwd_key3.style.visibility=vorh;
    document.all.pwd_key3.style.position=temp;
    //parent.TuneHeight('mainContent');
  }
	 
  </script>
	</head>

	<body>
		<c:if test="${user == null}">
			<c:set value="${sessionScope.learnsPrivilege.user}" var="user"></c:set>
		</c:if>
		<TABLE cellSpacing=2 cellPadding=2 border=0>
			<tr>
				<td width="718" height="27">
					<span style="padding-left: 13px;font-family: arial;font-size: 12px;font-weight: bold;">修改个人资料</span>
					<span style="padding-left: 470px"><a href="javascript:window.close()">CLOSE</a></span>
				</td>
			</tr>
			<tr>
				<td valign="top">
					<table width="100%" border="0" cellpadding="0" cellspacing="10"
						class="text">
						<tr>
							<td align="left">
								<form action="learnsUserAction.do" name="myform" method="post">
									<input type="hidden" name="id" value="${user.id}"}>
									<input type="hidden" name="action" value="update"}>
									<table align="center" cellpadding="0" width="700">
										<tr>
											<td align="left" width="100">
												<span class="text">用户名:</span>
											</td>
											<td align="left" width="300">
												<input type="text" readonly="true" name="nickname"
													value="${user.nickname}">
											</td>
											<td align="left"></td>
										</tr>
										<tr>
											<td>
												<span class="text">真实姓名:</span>
											</td>
											<td>
												<input type="text" name="name" value="${user.name}">
											</td>
											<td></td>
										</tr>
										<tr>
											<td>
												<span class="text">修改密码:</span>
											</td>
											<td>
												<input type="checkbox" onclick="toVisibility()" name="isUpdatePwd">
											</td>
											<td></td>
										</tr>

										<tr id="old_key" class="myVisibility">
											<td>
												<span class="text">旧口令:</span>
											</td>
											<td>
												<input type="password" name="oldPassword"><span class="asterisk">&nbsp;*</span>
											</td>
											<td></td>

										</tr>
										<tr id="pwd_key" class="myVisibility">
											<td>
												<span class="text">新口令:</span>
											</td>
											<td>
												<input type="password" name="password"><span class="asterisk">&nbsp;*</span>
											</td>
											<td><span style="padding-left: 40px" class="text">长度大于6</span></td>
										</tr>
										<tr id="pwd_key2" class="myVisibility">
											<td>
												<span class="text">口令确认:</span>
											</td>
											<td>
												<input type="password" name="password2"><span class="asterisk">&nbsp;*</span>
											<td><span style="padding-left: 40px" class="text">长度大于6</span></td>
										</tr>
										
										<c:if test="${user.passQuestion == null}">
											<tr>
												<td>
													<span class="text">设置密码保护问题:</span>
												</td>
												<td>
													<input type="checkbox" onclick="toVisibilityProtected()" name="isSetPwdQuest">
												</td>
												<td></td>
											</tr>
											<tr id="pwd_key3" class="myVisibility">
												<td>
													<span class="text">密码确认:</span>
												</td>
												<td><input type="password" name="password3"><span class="asterisk">&nbsp;*</span></td>
												<td><span style="padding-left: 40px" class="text">要设置密码提示问题，请输入密码</span></td>
											</tr>
											<tr id="trPassQuest" class="myVisibility">
												<td>
													<span class="text">密码提示问题:</span>
												</td>
												<td>
													<select name="passQuestion">
													<option value="您的宠物的名字？">您的宠物的名字？</option>
													<option value="您就读的第一所学校的名称？">您就读的第一所学校的名称？</option>
													<option value="少年时代心目中的英雄是谁？">少年时代心目中的英雄是谁？</option>
													<option value="您最喜欢的休闲运动是什么？">您最喜欢的休闲运动是什么？</option>
													<option value="您最喜欢的运动员是谁？">您最喜欢的运动员是谁？</option>
													<option value="您的第一辆汽车或自行车是什么牌子的？">您的第一辆汽车或自行车是什么牌子的？</option>
													<option value="您最喜欢哪支运动队？">您最喜欢哪支运动队？</option>
												</select>
												</td>
												<td></td>
	
											</tr>
											<tr id="trPassQuestAnswer" class="myVisibility">
												<td>
													<span class="text">密码提示答案:</span>
												</td>
												<td>
													<input type="text" name="passQuestionAnswer"><span class="asterisk">&nbsp;*</span>
												</td>
												<td><span style="padding-left: 40px" class="text">4个字符以上</span></td>
											</tr>
										</c:if>
										<tr>
											<td>
												<span class="text">生日:</span>
											</td>
											<td>
												<input type="text" name="birthday"
													value="<fmt:formatDate value="${user.birthday}" type="date" />"
													onfocus="calendar()">
											</td>
											<td></td>
										</tr>
										<tr>
											<td>
												<span class="text">用户类型:</span>
											</td>
											<td>
												<select name="userType">
													<option value="1"
														<c:if test="${user.userType==1}">selected</c:if>>
														学生
													</option>
													<option value="2"
														<c:if test="${user.userType==2}">selected</c:if>>
														家长
													</option>
													<option value="3"
														<c:if test="${user.userType==3}">selected</c:if>>
														过路人
													</option>
												</select>
											</td>
											<td></td>
										</tr>
										<tr>
											<td>
												<span class="text">学历:</span>
											</td>
											<td>
												<select name="degree">
													<option value="2">初一</option>
													<option value="3">初二</option>
													<option value="4">初三</option>
													<option value="5">高一</option>
													<option value="6">高二</option>
													<option value="7">高三</option>
													<option value="8">大学</option>
													<option value="9">硕士</option>
													<option value="10">其它</option>
												</select>
												<script language="javascript">
												document.myform.degree.value = ${user.degree == null ? 5 : user.degree};
												</script>
											</td>
											<td></td>
										</tr>
										
										<tr>
										   <td><span class="text">电话</span></td>
										   <td><input type="text" name="tel" value="${user.tel}"></td>
										   <td></td>
										</tr>
										   
										<tr>
										   <td><span class="text">地址</span></td>
										   <td><input type="text" name="address" value="${user.address}"></td>
										   <td></td>
										</tr>
										
										<tr>
											<td>
												<span class="text">简单介绍:</span>
											</td>
											<td>
												<textarea rows="4" cols="48" name="myIntroduction">${user.myIntroduction}</textarea>
											</td>
											<td></td>
										</tr>
											 
								    	<tr>
					                         <td><span class="text">验证码:</span></td>
					                         <td>                           
					                             <input type="text" name="number" size=8 maxlength="4">                           
					                             <jsp:include flush="true" page="rand.jsp" />                         
					                         </td>                           
					                         <td></td>
			                  	        </tr>	
										<tr>
											<td></td>
											<td>
												<input type="button" onclick="validata('<%=session.getAttribute("rand")%>')" value="提交">
												&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
												<input type="reset" value="重填">
											</td>
											<td>
												&nbsp;
											</td>
										</tr>
									</table>
								</form>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td align="center"><c:if test="${myMessage != null}">${myMessage}<br>点击<a href="javascript:window.close()">此处</a>关闭本页</c:if></td>
			</tr>
		</TABLE>
		<div class="div_copyright">
			Copyright @ 2007
			<a href="http://www.2collegeboard.com" target="_blank"
				class="a_copyright">2collegeboard.com</a> all right reserved.
		</div>
	</body>
</html>
